package cn.iocoder.yudao.module.train.dal.mysql.WxUser;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.train.dal.dataobject.WxUser.WxUserDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.train.controller.admin.wxuser.vo.*;

/**
 * 微信用户 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface WxUserMapper extends BaseMapperX<WxUserDO> {

    default PageResult<WxUserDO> selectPage(WxUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WxUserDO>()
                .eqIfPresent(WxUserDO::getUOpenId, reqVO.getUOpenid())
                .likeIfPresent(WxUserDO::getUName, reqVO.getUName())
                .eqIfPresent(WxUserDO::getUAvatar, reqVO.getUAvatar())
                .eqIfPresent(WxUserDO::getURole, reqVO.getURole())
                .eqIfPresent(WxUserDO::getUStatus, reqVO.getUStatus())
                .betweenIfPresent(WxUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WxUserDO::getId));
    }

    default WxUserDO selectByOpenId(String openId) {
        return selectOne(new LambdaQueryWrapperX<WxUserDO>()
                .eqIfPresent(WxUserDO::getUOpenId, openId));
    }
}
